<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/statics/js/jquery-3.6.0.js"></script>
    <script>
        $(function () {
            $("#btn").click(function () {
                $.post("${pageContext.request.contextPath}/a2", function (res) {
                    // console.log(res);
                    var html = "";
                    for (let i = 0; i < res.length; i++) {
                        html += "<tr>" +
                            "<td>" + res[i].name + "</td>" +
                            "<td>" + res[i].age + "</td>" +
                            "<td>" + res[i].sex + "</td>" +
                            "</tr>"
                    }
                    $("#content").html(html);
                });
            });
        })

    </script>
</head>
<body>
<input type="button" id="btn" value="加载数据">
<table>
    <tr>
        <td>姓名</td>
        <td>年龄</td>
        <td>性别</td>
    </tr>
    <tbody id="content">

    </tbody>
</table>
</body>
</html>
